<?php  ob_start();
/**
* @package		Parents@School
* @copyright	                Copyright (C) 2008 Kristof Beckers. All rights reserved.
* @Version		2.0
* @license		GNU/GPL, see LICENSE.php
**/
include ("../include/config.php");
include ("../include/db.php");
include ("../include/header.php");


// username and password sent from form
$myusername=$_POST['username'];
$password = $_POST['passwd'];
$mypassword = md5($password);
?>
<head>
<link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700,900" rel="stylesheet" />
<link href="../templates/alicebourg/default.css" rel="stylesheet" type="text/css" media="all" />
<link href="../templates/alicebourg/fonts.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<div id="wrapper">
	<div id="header-wrapper">
    	<div id="header" class="container">
        	<div id="logo">
            <h1>Reservaties ouderavond Alicebourg</h1>
            </div>
        </div>
        <div id="menu" class="container">
       <?php include ("../include/menu.php"); ?>
        </div>
     </div>
     <div id="page" class="container">
  <?php

$sql="SELECT * FROM $tbusers WHERE username='$myusername' AND password='$mypassword' ";
$result=mysql_query($sql);

while ($row = mysql_fetch_array($result)) {
   $username =  $row['username'];  
   $password = $row['password'];
   $usernameid = $row['ID'];
   $klas = $row['klas'];
   	$stamboeknr = $row['stamboeknr'];
	$straat = $row['straat'];
	$huisnr = $row['huisnr'];
	$postcode = $row['postcode'];
	$gemeente = $row['gemeente'];
}

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){
// Register $myusername, $mypassword and redirect back to the startpage.
$_SESSION['myusername'] = $myusername ;
$_SESSION['klas'] = $klas;
$_SESSION['loggedin'] = "TRUE";

// Check for doubles on the same address.
//Hier gaan we controleren op meerdere lln op het bovenstaande adres
			$sql1="SELECT * FROM $tbusers WHERE straat='$straat' AND huisnr='$huisnr' AND postcode='$postcode' AND gemeente='$gemeente'";
			$result1 = mysql_query($sql1) or die (mysql_error());
			
			// Tellen van het aantal rijen het resultaat weergeeft, indien gelijk dan of meer dan 2 gaan we de verschillende lln met hun klas weergeven.	
			$num_rows1 = mysql_num_rows($result1);
					if ($num_rows1 >= 2)
					{
						$_SESSION['multiple']="TRUE";
						header("location:../index.php");
					}
					else
					{
						////////////

					header("location:../index.php");
					}
}
else 
{
?>

Je gebruikersnaam of wachtwoord komen niet overeen.
<a href="../index.php">Probeer opnieuw</a>
  <?php 

}
mysql_close();
?>
</div>
</div>
</body>